//
// Created by Administrator on 2021/12/5.
//

#include "Utils.h"

mc_float Utils::mc_internal_length2(const mc_vec3f &v) {
    return v.x * v.x + v.y * v.y + v.z * v.z;
}

mc_float Utils::mc_internal_length(const mc_vec3f &v) {
    return std::sqrt(mc_internal_length2(v));
}

mc_vec3f Utils::mc_internal_normalize(const mc_vec3f &v) {
    mc_float vv = mc_internal_length(v);
    return mc_vec3f({v.x / vv, v.y / vv, v.z / vv});
}

mc_vec3f Utils::mc_internal_cross(const mc_vec3f &v1, const mc_vec3f &v2) {
    return mc_vec3f({v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x});
}
